<template>
  <view class="content">
    <!-- 背景图区域 -->
    <view class="bg-container">
      <image class="bg-image" src="/static/wine-cabinet.png" mode="aspectFill"></image>
    </view>
    
    <!-- 标题区域 -->
    <view class="title-container">
      <text class="main-title">选礼品，用助礼</text>
      <text class="sub-title">您的私人选礼小助理</text>
      <button class="experience-btn" @click="startExperience">点击体验</button>
    </view>
    
    <!-- 流程指引区域 -->
    <view class="guide-container">
      <view class="guide-item">
        <view class="guide-icon">
          <image src="/static/heart-icon.png" mode="aspectFit"></image>
        </view>
        <text class="guide-text">点击立即体验</text>
      </view>
      <view class="guide-arrow">
        <image src="/static/arrow-right.png" mode="aspectFit"></image>
      </view>
      <view class="guide-item">
        <view class="guide-icon">
          <image src="/static/people-icon.png" mode="aspectFit"></image>
        </view>
        <text class="guide-text">选择礼物对象与场景</text>
      </view>
      <view class="guide-arrow">
        <image src="/static/arrow-right.png" mode="aspectFit"></image>
      </view>
      <view class="guide-item">
        <view class="guide-icon">
          <image src="/static/gift-icon.png" mode="aspectFit"></image>
        </view>
        <text class="guide-text">浏览选择心仪的礼品吧</text>
      </view>
    </view>
  </view>
</template>

<script>
import wechat from '@/utils/wechat.js';
import { recordBrowse } from '@/api/user.js';

export default {
  data() {
    return {}
  },
  onLoad() {
    // 进入首页时静默登录
    this.silentLogin();
    
    // #ifdef MP-WEIXIN
    wx.showShareMenu({
      withShareTicket: true,
      menus: ['shareAppMessage', 'shareTimeline']
    })
    // #endif
  },
  methods: {
    // 静默登录方法
    silentLogin() {
      wechat.silentLogin()
        .then(userInfo => {
          console.log('静默登录成功', userInfo);
          // 统计浏览次数
          this.recordBrowse();
        })
        .catch(err => {
          console.error('静默登录失败', err);
          // 静默登录失败不做任何提示，用户仍可以使用应用
        });
    },

    // 记录浏览次数
    recordBrowse() {
      recordBrowse()
        .then(() => {
          console.log('浏览次数统计成功');
        })
        .catch(err => {
          console.error('浏览次数统计失败', err);
        });
    },
    startExperience() {
      // 跳转到选择页面
      uni.navigateTo({
        url: '/pages/select/select'
      })
    }
  }
}
</script>

<style lang="scss">
.content {
  min-height: 100vh;
  position: relative;
  background-color: #000;
}

.bg-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  
  .bg-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.8;
  }
}

.title-container {
  position: absolute;
  bottom: 534rpx;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  z-index: 2;
  
  .main-title {
    font-size: 56rpx;
    color: #ffffff;
    font-weight: bold;
    margin-bottom: 30rpx;
    letter-spacing: 4rpx;
  }
  
  .sub-title {
    font-size: 36rpx;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 80rpx;
    letter-spacing: 2rpx;
  }
  
  .experience-btn {
    background-color: #8B0000;
    color: #ffffff;
    width: 360rpx;
    height: 88rpx;
    line-height: 88rpx;
    border-radius: 2rpx;
    font-size: 34rpx;
    border: none;
    box-shadow: 0 4rpx 12rpx rgba(139, 0, 0, 0.3);
    letter-spacing: 2rpx;
    margin-bottom: -200rpx;
  }
}

.guide-container {
  position: absolute;
  bottom: 60rpx;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 620rpx;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 40rpx 30rpx;
  border-radius: 24rpx;
  box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.2);
  z-index: 2;
  
  .guide-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    
    .guide-icon {
      width: 88rpx;
      height: 88rpx;
      margin-bottom: 16rpx;
      
      image {
        width: 100%;
        height: 100%;
      }
    }
    
    .guide-text {
      font-size: 26rpx;
      color: #ffffff;
      text-align: center;
      letter-spacing: 1rpx;
    }
  }
  
  .guide-arrow {
    width: 44rpx;
    height: 44rpx;
    margin: 0 24rpx;
    opacity: 0.7;
    
    image {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
